package cn.monkey.service;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class ScheduleService {
//    @Scheduled(fixedRate = 5000)    //fixedRate,第一次开始执行之后延迟时间
//    public void testOne(){
//        System.out.println(new Date(System.currentTimeMillis()));
//    }

//    @Scheduled(initialDelay = 1000,fixedRate = 5000)    //initialDelay第一次延迟时间
//    public void testTwo(){
//        System.out.println(new Date(System.currentTimeMillis()));
//    }
    @Scheduled(fixedDelay = 5000)    //fixedDelay,上一次执行完毕后延迟时间
    public void testThree() throws InterruptedException {
        System.out.println(new Date(System.currentTimeMillis()));
        Thread.sleep(5000);
    }
}
